package main

func oneEditAway(first string, second string) bool {
	if len(first) < len(second) {
		first, second = second, first
	}
	maxL := len(first)
	minL := len(second)
	if maxL-minL > 1 {
		return false
	}
	//两个字符串长度相等
	if maxL == minL {
		f := 0
		for i := 0; i < minL; i++ {
			if first[i] != second[i] {
				f++
				if f > 1 {
					return false
				}
			}
		}
		return true
	}
	//两个字符串长度差1
	f := 0
	for i, j := 0, 0; i < maxL && j < minL; i++ {
		if first[i] == second[j] {
			j++
		} else {
			f++
			if f > 1 {
				return false
			}
		}
	}
	return true
}
